﻿using ProjectScheduling.daos;
using ProjectScheduling.models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ProjectScheduling
{
    public partial class ViewProjectForm : Form
    {
        public readonly static ViewProjectForm b = new();
        private ViewProjectForm()
        {
            InitializeComponent();
        }
        public void Init(int id)
        {
            var p = ProjectDao.Base.Find(id);
            if (p == null)
            {
                return;
            }
            txt_type.Text = p.ProjectType?.Name ?? "";
            txt_customer.Text = p.CustomerName;
            txt_linker.Text = p.Linker;
            txt_phone.Text = p.Phone;
            txt_name.Text = p.Name;
            txt_address.Text = p.Address;
            txt_contract_state.Text = p.ContractState;
            txt_appstate.Text = p.ApproveState;
            txt_plan_start.Text = p.PlanStartDate.ToString("yyyy年MM月dd日");
            txt_sale_name.Text = p.Sales?.TrueName ?? "";
            txt_days.Text = p.Days.ToString();
            txt_rate.Text = p.Rate.ToString();
            txt_start.Text = p.FromDate.ToString("yyyy-MM-dd日HH时");
            txt_end.Text = p.ToDate.ToString("yyyy-MM-dd日HH时");
            txt_descript.Text = p.Description;
            txt_staffs.Text = string.Join("、", p.StaffsList?.Select(it => it.UserName) ?? []);
            txt_ownership.Text = p.OwnerShip ?? "";
            ShowDialog();
        }
    }
}
